const path = require('path');
const { VueLoaderPlugin } = require('vue-loader')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ip = require('ip').address();

const webpackConfig = {
  mode: "development",
  entry: {
    index: './src/view/index.js',
  },
  output: {
    path: path.resolve(__dirname, './dist'),
    publicPath: '/',
    filename: '[name].js',
  },
  resolve: {
    extensions: ['.js', '.vue'],
    alias: {
      'vue': 'vue/dist/vue',
      '@': path.resolve(__dirname, './src'),
      'vendor': path.resolve(__dirname, '../src/vendor'),

    }
  },
  devServer: {
    host: 'localhost',
    host: ip,
    inline: false,
    // port: 8088,
    publicPath: '/',
    proxy: {
      '/api': {
        target: 'http://192.168.0.105:28001/wanfeng', // 商户接口的域名
        // target: 'http://101.132.45.40:9091/ms', // 商户接口的域名
        // target: 'http://101.132.45.40:9190/ms', // 测试接口的域名
        // target: 'http://192.168.1.7:9090/ms', // 金山商户接口的域名
        // target: 'http://192.168.1.7:9091/ms', // 金山运营接口的域名
        // target:'http://192.168.2.195:9190/ms', // 谓军接口的域名
        // target:'http://192.168.1.4:9090/ms',//吴昊接口域名
        // target:'http://192.168.1.4:9091/ms',//吴昊接口域名
        secure: false,
        changeOrigin: false,
        pathRewrite: { '^/api': '' },
      }
    },
  },
  plugins: [
    new VueLoaderPlugin(),
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: 'index.html',
      title: '萬蜂',
      inject: true,
      chunks: ['index'],
      hash: true,
    }),
  ],
  module: {
    rules: [
      { test: /\.js$/, exclude: /node_modules/, use: { loader: 'babel-loader', } },
      { test: /\.json$/, use: 'json-loader' },
      { test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192' },
      { test: /\.vue$/, use: 'vue-loader' },
      { test: /\.css$/, loader: 'style-loader!css-loader' },
      { test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/, loader: 'file-loader?name=font/[name]-[hash].[ext]' },

    ]
  }
};
module.exports = webpackConfig